#coding:utf-8
import json
from django.http import HttpResponse
from django.views.decorators.cache import cache_page
from lovewith.promote.views.modules.home import HomeApi



#查询结果缓存10分钟
@cache_page(10 * 60)
def get_homepage_data(request):
    page_no = int(request.GET.get('page', 1))
    share_data = HomeApi.get_home_choice_data(page_no)

    the_share_data = []
    if share_data and share_data.has_key('share'):
        the_share_data = share_data.get('share')

    result = {
        'page': page_no,
        'data': the_share_data
    }

    return HttpResponse(json.dumps(result))